package main

import (

	"guo"
	"net/http"
)
func main(){
	r:=guo.Default()
	r.Use(guo.Logger())
	r.GET("/",func(c *guo.Context){
		c.HTML(http.StatusOK,"<h1>hello Guo</h1>")
	})
	r.GET("/hello",func(c *guo.Context){
		c.String(http.StatusOK,"hello %s,you`re at %s\n",c.Query("name"),c.Path)
	})
	r.GET("/hello/:name",func(c *guo.Context){
		c.String(http.StatusOK,"hello %s,you are at %s\n",c.Param("name"),c.Path)
	})
	r.POST("/login",func(c *guo.Context){
		c.JSON(http.StatusOK,guo.H{
			"username":c.PostForm("username"),
			"password":c.PostForm("password"),
		})
	})
	r.GET("/panic",func(c *guo.Context){
		names:=[]string{"vane"}
		c.String(http.StatusOK,names[100])
	})
	r.GET("/assets/*filepath",func(c *guo.Context){
		c.JSON(http.StatusOK,guo.H{"filepath":c.Param("filepath")})
	})
	v1:=r.Group("/v1")
	{
		v1.GET("/hello",func(c *guo.Context){
			c.String(http.StatusOK,"hello %s",c.Query("name"))
		})
		v1.GET("/hello/:name",func(c *guo.Context){
			c.String(http.StatusOK,"hello %s,you`re at %s",c.Param("name"),c.Path)
		})

	}
	r.Run(":9999")

}